<template>
  <div class="stat-card" :style="{ '--card-color': color }" :class="{ 'customer-count': isCustomerCount }">
    <div class="stat-info">
      <div class="stat-title">{{ title }}</div>
      <div class="stat-value" v-if="!isCustomerCount">{{ value }}</div>
    </div>
    <div class="stat-circle">
      <svg width="100%" height="100%" viewBox="0 0 100 100">
        <circle cx="50" cy="50" r="45" fill="none" stroke="rgba(255, 255, 255, 0.1)" stroke-width="5" />
        <circle cx="50" cy="50" r="45" fill="none" stroke="var(--card-color)" stroke-width="5" stroke-dasharray="283" stroke-dashoffset="70" />
      </svg>
      <div v-if="isCustomerCount" class="circle-value">{{ value }}</div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      required: true
    },
    value: {
      type: [String, Number],
      required: true
    },
    color: {
      type: String,
      default: '#4B7BEC'
    },
    isCustomerCount: {
      type: Boolean,
      default: false
    }
  }
};
</script>

<style scoped>
.stat-card {
  background-color: #282A42;
  border-radius: 10px;
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 18%;
  --card-color: #4B7BEC;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-title {
  font-size: 14px;
  color: #8C9EFF;
  margin-bottom: 5px;
}

.stat-value {
  font-size: 24px;
  font-weight: bold;
  color: #fff;
}

.stat-circle {
  width: 80px;
  height: 80px;
  position: relative;
}

.stat-circle svg {
  transform: rotate(-90deg);
}

/* 总客户数特殊样式 */
.customer-count .stat-circle {
  width: 100px;
  height: 100px;
}

.customer-count .stat-title {
  font-size: 16px;
  font-weight: bold;
}

.circle-value {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px;
  font-weight: bold;
  color: #fff;
}

.customer-count {
  background-color: rgba(75, 123, 236, 0.2);
  border: 1px solid var(--card-color);
}
</style> 